import { getBaseUrl } from '@/services/urlconst';

/**统一请求IP*/
export const getRequestIp = () => {
  /**线上服务器*/
  let url = getBaseUrl();
  /**Mock数据*/
  // let url = '/testApi';
  /**郭宇热点 袁振豪服务IP地址*/
  // let url = 'http://192.168.29.20:31019';
  /**袁振豪热点 袁振豪服务IP地址*/
  // let url = 'http://192.168.40.20:31019';
  /**海淀办公室 袁振豪服务IP地址【wifi:zkgl】*/
  // let url = 'http://192.168.1.33:31019';
  /**怀柔实验室 袁振豪服务IP地址【wifi:MAX-191】*/
  // let url = 'http://192.168.153.192:31019';
  /**格林豪泰 wifi*/
  // let url = 'http://192.168.43.87:31019';
  return url;
};

/** 生成随机流水单号 */
export function generateRandomNumber(type = 'SOURCE_') {
  const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  let number = '';
  for (let i = 0; i < 4; i++) {
    number += letters.charAt(Math.floor(Math.random() * letters.length));
  }
  return type + number + Math.floor(Math.random() * 1000000000);
}

/** 拆分数据 */
export const splitExpertData = (data, type) => {
  if (!data?.length || !data) return [];
  return data?.filter((item) => item.sourceType == type);
};

/**
 * setTableRowClassName 设置表格单双行类名
 */
export const setTableRowClassName = (_: Record<string, any>, index: number) => {
  return index % 2 == 0 ? 'double-row' : 'default-row';
};
